﻿@using Newtouch.Common.Operator;
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="form1">
    <div class="container" style="margin-top: 10px; margin-left: -4%; ">
        <ul class="nav nav-tabs" role="tablist" id="myTab" style="margin-left: 4%;">
            <li role="presentation"><a role="tab" data-toggle="tab">基本信息</a></li>
        </ul>
        <div class="tab-content">
            <div role="tabpanel" id="divPatInfo" class="tab-pane fade in active" style="padding-top: 20px; margin-right: 30px;">
                <table class="form">
                    <tr>
                        <th class="formTitle"><span class="required">*</span>病历号：</th>
                        <td class="formValue">
                            <input type="text" class="form-control" style="width:56%; float:left" id="blh" required />
                            &nbsp;&nbsp;<input type="button" class="btn btn-default btn-md btn-default-color" title="选择住院病人" style="width: 25px;" id="btnsyy" value="查询" onclick="GetPatSerarchView($('#blh').val());">
                        </td>
                        <th class="formTitle">保险公司：</th>
                        <td class="formValue">
                            <input id="bxName" class="form-control" type="text">
                        </td>

                    </tr>
                    <tr>
                        <th class="formTitle"><span class="required">*</span>病人内码：</th>
                        <td class="formValue">
                            <input type="text" class="form-control newtouch_Readonly" id="patId" required />
                        </td>
                        <th class="formTitle">姓名：</th>
                        <td class="formValue">
                            <input type="text" class="form-control newtouch_Readonly" id="xm" required />
                        </td>

                    </tr>
                    <tr>
                        <th class="formTitle">年龄：</th>
                        <td class="formValue">
                            <input type="text" class="form-control newtouch_Readonly" id="nlshow" required />
                        </td>
                        <th class="formTitle">有效</th>
                        <td class="formValue">
                            <div class="ckbox">
                                <input id="zt" type="checkbox" checked="checked"><label for="zt"></label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        >
                        <th class="formTitle"><span class="required">*</span>开始日期：</th>
                        <td class="formValue">
                            <input id="ksrq" type="text" class="form-control input-wdatepicker" value="" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" required />
                        </td>
                        <th class="formTitle"><span class="required">*</span>结束日期：</th>
                        <td class="formValue">
                            <input id="jsrq" type="text" class="form-control input-wdatepicker" value="" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" required />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle"><span class="required">*</span>总次数：</th>
                        <td class="formValue">
                            <input type="text" class="form-control" id="zcs" required />
                        </td>
                        <th class="formTitle"><span class="required">*</span>剩余次数：</th>
                        <td class="formValue">
                            <input type="text" class="form-control newtouch_Readonly" id="sycs" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle"><span class="required">*</span>建档人员：</th>
                        <td class="formValue">
                            <input class="form-control newtouch_Readonly" id="CreatorCode" value=@OperatorProvider.GetCurrent().UserCode type="text" required />
                        </td>
                        <th class="formTitle"><span class="required">*</span>建档日期：</th>
                        <td class="formValue">
                            <input class="form-control newtouch_Readonly" id="CreateTime" value=@DateTime.Now.ToString("yyyy-MM-dd") type="text" required />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</form>
<script>
    var sbbabId = $.request("sbbabId");
    $(function () {
        if (!!sbbabId) {
            $.ajax({
                url: "/InsuranceManage/CommercialInsuranceFiling/GetFormJson?r=" + Math.random(),
                data: { sbbabId: sbbabId },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    if (data["bxCode"]) {
                        $("#bxName").attr("data-label", data["bxCode"]);
                    }
                    $("#ksrq").val((data.ksrq && data.ksrq.length >= 10 ? data.ksrq.substring(0, 10) : ""));
                    $("#jsrq").val((data.jsrq && data.jsrq.length >= 10 ? data.jsrq.substring(0, 10) : ""));
                }
            });
            $("#sycs").removeAttr("disabled").css("background-color", "white");
        }

    });

    //门诊病人查询
    function GetPatSerarchView(blh) {
        if (!!!blh) {
            blh = '';
        }
        $.modalOpen({
            id: "patSearch",
            title: "患者查询",
            url: " /OutpatientManage/OutpatientAccounting/SysPatEntitiesblhView?t=" + Math.random() + "&from=Form&blh=" + blh,
            width: "700px",
            height: "400px",
            callBack: function (iframeId) {
                top.frames[iframeId].PatDbGrid(); //在弹出窗口事件
            }//窗口点确定的回调函数
        });
    }

    //选择的病人
    function GetQueryFphAjax(selePatInfo) {
        $('#blh').val(selePatInfo.blh);
        $("#patId").val(selePatInfo.patid);
        $("#xm").val(selePatInfo.xm);
        $("#nlshow").val(selePatInfo.nlshow);
        // ajaxLoadDataResult();
    }

    ///报销政策
    $("#bxName").newtouchFloatingSelector({
        height: 200,
        width: 300,
        filter: function (keyword) {
            if (!keyword) {
                return null;
            }
            //遍历数据源，用keyword来筛选出结果
            var resultObjArr = new Array();
            $.each(top.window.clients.commercialInsuranceList, function (idx, val) {
                if ((val.bxCode && val.bxCode.toLowerCase().indexOf(keyword.toLowerCase()) >= 0) || keyword.trim() === "") {
                    resultObjArr.push(val);
                }
            });
            return resultObjArr;

        },
        caption: "商保公司",
        colModel: [
            {
                label: '代码', name: 'bxCode', widthratio: 25
            },
            {
                label: '名称', name: 'Name', widthratio: 25
            },
            { label: '英文', name: 'EnglishName', widthratio: 25 }
        ],
        itemdbclickhandler: function ($thistr) {
            $("#bxName").attr("data-label", $thistr.find("td:eq(0)").html());
            $("#bxName").val($thistr.find('td:eq(1)').html());
            return;
        }
    });

    $("#zcs").bind("keydown blur keyup", function (e) {
        if ((e.keyCode === 13 && e.type === "keydown") || e.type === "blur" || e.type === "keyup") {
            $('#sycs').val($('#zcs').val());
        }
    });
    //提交
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var params = $("#form1").formSerialize();
        params["bxCode"] = $("#bxName").attr("data-label");
        $.submitForm({
            url: "/InsuranceManage/CommercialInsuranceFiling/SubmitForm?sbbabId=" + sbbabId,
            param: params,
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }

</script>
